<template>
    <div class="t1">  
        <table> </table>
        <div class="d1">
         <router-link to="/" slot="left">
         <img class="img" src="/img/index/back.png" alt="">
         </router-link>
         <div class="in1"><span>|</span>  <img src="/img/index/search.png" alt=""><input v-model="searchKey" style="border:0;background:#f4f4f4" type="text" placeholder="快速搜索你想要的机型"></div>
    </div>

    <div class="r1"> 热门搜索</div>
    <router-link :to="`/prospecs?proid=${item.id}&protitle=${item.name}&proprice=${item.prise}&propic=${item.photo_url}`" v-for="(item,i) of search" :key="i">
    <div class="p1">
         {{item.name}}
    </div>
    </router-link>
    </div>
</template>

<style scoped>
   .t1 .p1{
    display: inline-block;
    font-size: 13px;
    background: #f7f8fa;
    padding: 10px 10px;
    color: #333;
    margin: 0 10px 15px 15px;

    }
    .r1{
        color: #000;
        font-size: 16px;
        padding: 15px
    }
    .d1{
        
        border-radius: 10px;
        display: flex;
        align-items: center;
        height: 45px;
        background: #f4f4f4;
        margin: 10px
    }
    .img {
        
        height: 20px;
        width: 20px;
        float: left;
        padding-left: 15px;
       
    }
    .in1 span{
        padding: 0 10px ;
        color: #ddd9d9;
    }
    .in1{
        color:#999;
        margin-left: 15px;
        line-height: 45px;
        padding-top: 2px;
       
        display: inline-block
    }
    .in1 img{
        height: 25px;
        width: 25px;
    }
</style>
<script>
export default {
    data(){
        return {
        searchKey:"",
        searchPro:[]
        }
    },
    mounted(){
        this.axios.get("/products/index?pno=1&count=1000").then(res=>{
            this.searchPro = res.data.data;
        })
    },
    computed:{
        // 获取计算后的属性
        search(){
            if(!this.searchKey){
                return this.searchPro
            }
            return this.searchPro.filter(item=>item.name.includes(this.searchKey))
        }
    }
}
</script>